package com.cv.system.dal.mapper.role;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.utils.object.BeanUtils;
import com.cv.framework.mybatis.core.mapper.BaseMapperX;
import com.cv.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cv.system.controller.system.role.vo.RolePageReqVO;
import com.cv.system.controller.system.role.vo.RoleRespVO;
import com.cv.system.dal.dataobject.role.SystemRoleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 角色数据层
 *
 * @author Charles_XDXD
 */
@Mapper
public interface SystemRoleMapper extends BaseMapperX<SystemRoleDO> {

    default PageResult<RoleRespVO> selectPage(RolePageReqVO pageReqVO) {
        LambdaQueryWrapperX<SystemRoleDO> wrapperX = new LambdaQueryWrapperX<SystemRoleDO>()
                .likeIfPresent(SystemRoleDO::getName, pageReqVO.getName())
                .likeIfPresent(SystemRoleDO::getCode, pageReqVO.getCode())
                .eqIfPresent(SystemRoleDO::getStatus, pageReqVO.getStatus())
                .betweenIfPresent(SystemRoleDO::getCreateTime, pageReqVO.getCreateTime());

        PageResult<SystemRoleDO> result = selectPage(pageReqVO, wrapperX);
        return BeanUtils.toBean(result, RoleRespVO.class);
    }

}
